<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
 <c:set var="path" value="${pageContext.request.contextPath}"/>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="${path}/pages/">
<meta charset="UTF-8">
<title>注册</title>
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="../layui/css/layui.css">

</head>
<body>

<div class="login layui-anim layui-anim-upbit">
<div class='login_title'>

<h5><pre>         每部电影的的男主才是电影的真身</pre></h5>

</div>
<div class="layui-form" >
	<input type="hidden" name="id" value="${user.id}">
  <div class="layui-form-item">
    <label class="layui-form-label">用户名</label>
    <div class="layui-input-inline">
      <input style="width: 190px" type="text" name="userName" value="${user.userName}" required  lay-verify="required|username" placeholder="请输入用户名" autocomplete="off" class="layui-input">
    </div>
    
  </div>
  <div class="layui-form-item">
    <label  class="layui-form-label">手机号</label>
    <div class="layui-input-inline">
      <input style="width: 190px" type="text"  name="phoneNumber" value="${user.phoneNumber}" required  lay-verify="required|phone" placeholder="请输入手机号" autocomplete="off" class="layui-input">
    </div>
     
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">密码</label>
    <div class="layui-input-inline">
      <input type="password" name="password"  id="password"value="${user.password}" required lay-verify="required|password" placeholder="数字和字母，6-16位" autocomplete="off" class="layui-input">
    </div>
   <div class="layui-form-mid layui-word-aux" ></div>
    </div>
<div class="layui-form-item">
    <label class="layui-form-label">重复密码</label>
    <div class="layui-input-inline">
      <input type="password" name="repassword" id ="repassword" required lay-verify="required|repassword" placeholder="请确认密码" autocomplete="off" class="layui-input">
    </div>
    
  </div>
  
  
    
  <div class="layui-form-item">
    <label class="layui-form-label">邮箱号</label>
    <div class="layui-input-block">
      <input style="width: 190px" type="text" name="email"  id="email" required  lay-verify="required|email" value="${user.email}" placeholder="请输入邮箱" autocomplete="off" class="layui-input">
    </div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">性别</label>
    <div class="layui-input-block">
      <input type="radio" name="sex" value="男" title="男">
      <input type="radio" name="sex" value="女" title="女" checked>
    </div>
  </div>

  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
      <button onclick="javascript:window.location.href='login.jsp'" class="layui-btn">登录</button>
    </div>
  </div>
</div>
</div>
<script src="../layui/layui.js"></script>
<script>
//Demo
/*  name=
   用户名:UName
   密码:Pd
   重新输入的密码:RePd
   手机号:PhoneNb
   邮箱号:Email
 */
layui.use('form', function(){
  var form = layui.form;
  var $ = layui.$;
  
  form.verify({
	  username: function(value, item){ //value：表单的值、item：表单的DOM对象
	    if(!new RegExp("^[a-zA-Z0-9_\u4e00-\u9fa5\\s·]+$").test(value)){
	      return '用户名不能有特殊字符';
	    }
	    if(/(^\_)|(\__)|(\_+$)/.test(value)){
	      return '用户名首尾不能出现下划线\'_\'';
	    }
	    if(/^\d+\d+\d$/.test(value)){
	      return '用户名不能全为数字';
	    }
	  },
  		
  	password:function(value, item){ //value：表单的值、item：表单的DOM对象
	    if(!new RegExp("^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$").test(value)){
		      return '密码格式不正确';
	    }
	},
	repassword:function(value ,item){
		if($('#password').val()!=value){
			return '密码不一致'
		}
	},
  	email:	function(value, item){ //value：表单的值、item：表单的DOM对象
	    if(!new RegExp("^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$").test(value)){
	    	 return '邮箱格式不正确';
	    }
	}
	  
	
	});   
  
  
  //监听提交
	form.on('submit(formDemo)', function(data) {
		$.post('${path}/action/user/save', data.field, function(json) {
				
			 		
					window.location.href = '${path}/pages/login.jsp';
			}, 'JSON');
	});
  

  

});
</script>

</body>
</html>


